/*
 * @Author: pengpeng 
 * @Date: 2019-08-29 09:12:53 
 * @Last Modified by: pengpeng
 * @Last Modified time: 2019-09-03 21:08:50
 */
const Koa = require('koa')
const ejs = require('ejs')
const pug = require('pug')
const app = new Koa()
const views = require('koa-views')
const {
  resolve
} = require('path')
// const {
//   htmlTpl,
//   ejsTpl,
//   pugTpl
// } = require('./tpl')
app.use(views(resolve(__dirname, './views'), {
  extension: 'pug'
}))
// app.use(async (ctx, next) => {
//   ctx.type = 'text/html; charset=utf-8'
//   // ctx.body = ejs.render(ejsTpl, {
//   //   you: 'cai',
//   //   me: 'd'
//   // })
//   ctx.body = pug.render(pugTpl, {
//     you: 'cai',
//     me: 'd'
//   })
// })
app.use(async (ctx, next) => {
  await ctx.render('./index', {
    you: 'cai',
    me: 'd'
  })
})
app.listen(4000)